
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    loadingMoreHidden: true,
    CurrentPage: 1,
    pic1:"",
    productList:[],
    starArr1: [
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 0 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 0 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 0 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 0 }
    ],
    starArr2: [
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 0 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 0 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 0 }
    ],
    starArr3: [
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 0 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 0 }
    ],
    starArr4: [
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 0 }
    ],
    starArr5: [
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 },
      { pic: "/images/nav/star.png", pic2: "/images/nav/star2.png", star: 1 }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.myPingJiaList()
  },
  
  //获取我的评价列表
  myPingJiaList:function(){
    var that = this;
    wx.request({
      url: app.globalData.host + '/api/User/GetUserProductReviewList?uid=' + app.globalData.userInfo.Uid + '&pageSize=8&pageNumber=' + that.data.CurrentPage,
      success: function(res) {
        if(res.data.Code == 0){
          var newProductList = []
          var ProductReviewList = res.data.Data 
          if (ProductReviewList.length > 0){
            for (var i = 0; i < ProductReviewList.length; i++) {
              var h = ProductReviewList[i]
              h.PShowImg = app.globalData.image800_800host + ProductReviewList[i].PShowImg
              newProductList.push(h)
            }
            if (that.data.CurrentPage != 1) {
              var preGoods = that.data.productList
              newProductList = preGoods.concat(newProductList);
            }
            that.setData({
              productList: newProductList,
              loadingMoreHidden: true
            })
          }else{
            that.setData({
              loadingMoreHidden: false
            })
          }
        }
      }
    })
  },
  loadMorelist: function (e) {
    var that = this;
    if (!that.data.loadingMoreHidden) return;
    var currPage = that.data.CurrentPage;
    that.setData({
      CurrentPage: currPage + 1
    })
    that.myPingJiaList();
  },
  //点击图片预览
  previewImage: function (e) {
    var that = this;
    var current = e.currentTarget.dataset.src;
    var index = e.currentTarget.dataset.index;
    var strip = e.currentTarget.dataset.strip;
    wx.previewImage({
      current: current,
      urls: ['https://static.711688.net.cn/upload/user/source/' + that.data.productList[strip].ReviewPic_1,
        'https://static.711688.net.cn/upload/user/source/' + that.data.productList[strip].ReviewPic_2,
        'https://static.711688.net.cn/upload/user/source/' + that.data.productList[strip].ReviewPic_3,
        'https://static.711688.net.cn/upload/user/source/' + that.data.productList[strip].ReviewPic_4,
      ]
    })
  },
  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})